package com.xiaobias.mySwitch;

public class Switch003 {

    public static void main(String[] args) {
        before();
        after();
    }

    public static void before() {
        String name = "许庶";
        String country;
        switch (name) {
            case "周瑜":
            case "许庶":
                System.out.println("三国");
                country = "三国";
                break;
            case "成吉思汗":
            case "忽必烈":
                System.out.println("元朝");
                country = "元朝";
                break;
            case "韩信":
            case "刘邦":
                System.out.println("汉朝");
                country = "汉朝";
                break;
            default:
                System.out.println("未知");
                country = "未知";
                break;
        }
        System.out.println("Country: " + country);
    }

    public static void after() {
        String name = "许庶";
        String country = switch (name) {
            case "周瑜", "许庶" -> {
                System.out.println("三国");
                yield "三国";
            }
            case "成吉思汗", "忽必烈" -> {
                System.out.println("元朝");
                yield "元朝";
            }
            case "韩信", "刘邦" -> {
                System.out.println("汉朝");
                yield "汉朝";
            }
            default -> {
                System.out.println("未知");
                yield "未知";
            }
        };
        System.out.println("国家：" + country);
    }

    ;
}
